home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 4_0 / STANDALO / SQUARANT / SQUARANT.H < prev   
Text File  |  1990-11-15  |  5KB  |  156 lines

  1. /***********************************************************************************
  2.  
  3.     SIMPLE SYSTEMS¬ CLASS LIBRARY
  4.     
  5.         SQuarantine.h
  6.             
  7.             This is a class for virus protection.  This object scans each
  8.             resource in the given resource file and compares the resource
  9.             profile against a static table.  All differences are reported
  10.             according to the search criteria.
  11.             
  12.             This source code is released for limited use, any commerical
  13.             product that uses this source code should acknowledge the author,
  14.             Schorschi LeRoy Decker, in the manual documentation and/or in the
  15.             'About...' window for his creative effort.
  16.             
  17.         Version 1.0.0  11/10/90  
  18.         Schorschi LeRoy Decker
  19.         
  20.             Made some documentation changes.
  21.             
  22.         Version 1.0.1  11/15/90
  23.         Schorschi LeRoy Decker
  24.         
  25.  ***********************************************************************************
  26.  
  27.     IN NO WAY, SHAPE, OR FORM IS THIS FILE RELEASED TO BUSINESS ENTITIES THAT
  28.     CHARGE A FEE FOR DISTRIBUTION.  FIRMS LIKE EDUCORP¬, WHICH CHARGE DISTRIBUTION
  29.     FEES FOR PUBLIC DOMAIN OR SHAREWARE PRODUCTS, MUST RECEIVE WRITTEN PERMISSION
  30.     FROM SIMPLE SYSTEMS¬ AND THE ORIGINAL AUTHOR OF THIS SOURCE CODE.  BULLETIN BOARD
  31.     SYSTEMS AND ON-LINE SERVICES THAT CHARGE A CONNECT FEE ARE GIVEN LIMITED
  32.     PERMISSION FOR DOWNLOAD ACCESS BY MEMBERS.  ANY VIOLATION OF THIS RESERVED RIGHT 
  33.     OF LIMITED DISTRIBUTION WILL BE INFORCED TO THE FULLEST EXTENT OF THE LAW.
  34.     
  35.     COPYRIGHT ⌐ 1990 SIMPLE SYSTEMS¬.  ALL RIGHTS ARE RESERVED WORLD-WIDE.
  36.     
  37.         SIMPLE SYSTEMS¬ is the trademark and property of SIMPLE SYSTEMS CONSULTING.
  38.         EDUCORP¬ is the trademark and property of EDUCORP Inc.
  39.         
  40.  ***********************************************************************************
  41.  
  42.     SQuarantine 'Qnte' custom resource format notes...
  43.     
  44.         Each valid resource in a given resource file should have a record
  45.         in the appropiate quarantine table, resource type 'Qnte', which
  46.         includes the resource type, id, size, and name.  The format is
  47.         given below:
  48.         
  49.             Flags    Type    ID        Size    Name
  50.             --------------------------------------------------------------
  51.             0        BNDL    128        36        "\pThis sample 'Qnte' record."
  52.             0        FREF    128        54        "\pThis another sample."
  53.  
  54.             ***** one record for each expected, and valid, resource. *****
  55.                 
  56.             0        ....    0        -1        "\p"
  57.             --------------------------------------------------------------
  58.  
  59.         Note the size field of the last record.  The End-of-File, or in this
  60.         case, the End-of-Table marker is a size field initialized to -1.  If
  61.         the last record does not have a size field set to -1 then the scan
  62.         methods of the SQuarantine object will run in an endless loop until
  63.         la bomba.
  64.         
  65.         The included template for ResEdit, "'Qnte' Resource Template."  The
  66.         template does NOT generate an End-of-Table record.  The End-of-Table
  67.         record must be manually entered like all other records.
  68.     
  69.     Notes about applications that modify resources...
  70.     
  71.         An application should never modify or change its own resources, but...
  72.         
  73.         Any application that modifies a resource type, id, size or name so that
  74.         the corresponding resource record in the 'Qnte' resource does not match
  75.         will cause SQuarantine to generate a false virus or anomaly result.  
  76.         Besides, an application that modify its own resources in the realm of 
  77.         bad karma!
  78.         
  79.         A solution to this problem is to establish a given size for the changable
  80.         resource and pack null bytes as necessary to maintain the established size.
  81.         Of course, the changing of a type, id number, or name of a resource by an
  82.         application is really bad karma!!
  83.         
  84.  ***********************************************************************************
  85.         
  86.     Questions, comments, etc.
  87.     
  88.         To: SIMPLE SYSTEMS
  89.             Schorschi LeRoy Decker
  90.             5067 Golden Ave.
  91.             Riverside, CA  92505
  92.  
  93.         America-On-Line:    Schorschi
  94.         CompuServe:            73020,546
  95.         
  96.         Phone:    (714) 597-1234    Please not after 11:00 pm (Pacific) or before
  97.                                 7:00 am (Pacific).
  98.  
  99.  ***********************************************************************************/
  100.  
  101. #include <CObject.h>
  102.  
  103. /***********************************************************************************/
  104.  
  105. #define    kTypeAndID            8
  106. #define    kName                4
  107. #define    kSize                2
  108.  
  109. #define    kQuarantineShift    12
  110.  
  111. #define    rQuarantineType        'Qnte'
  112. #define    rQuarantineNumber    128
  113.  
  114. /***********************************************************************************
  115.     
  116.     The following structure declaration is used to define the a resource verification
  117.     table record, which is actually a segment of the 'Qnte' resource handle.
  118.  
  119.  ***********************************************************************************/
  120.  
  121. typedef struct QuarantineRec
  122.     {
  123.         int        flags;
  124.         long    type;
  125.         int        id;
  126.         long    size;
  127.         Str255    name;
  128.     } QuarantineRec, *QuarantinePtr, **QuarantineHdl;
  129.  
  130. /***********************************************************************************/
  131.  
  132. struct SQuarantine : CObject
  133.     {
  134.         /* Instance Variables. */
  135.         
  136.         StringHandle    theQuarantineMap;
  137.         int                theQuarantineFile;
  138.  
  139.         /* Instance Methods. */
  140.         
  141.         void        IQuarantine(int);
  142.         void        Dispose(void);
  143.         
  144.         Boolean        Scan(int);
  145.         Boolean        TypeAndID(Handle);
  146.         Boolean        Size(Handle);
  147.         Boolean        Name(Handle);
  148.         Boolean        Missed(void);
  149.     };
  150.  
  151. /***********************************************************************************
  152.  
  153.     End of File - SQuarantine.h
  154.     
  155.  ***********************************************************************************/
  156.